github.com/hyperion-hyn/go-ethereum@v2.4.0+incompatible/docs/Getting Started/running.md (about)

     1  # Running Quorum
     2  
     3  ## Developing Smart Contracts
     4  Quorum uses standard [Solidity](https://solidity.readthedocs.io/en/develop/) for writing Smart Contracts, and generally, these can be designed as you would design Smart Contracts for Ethereum.  Smart Contracts can either be public (i.e. visible and executable by all participants on a given Quorum network) or private to one or more network participants.  Note, however, that Quorum does not introduce new contract Types. Instead, similar to [Transactions](../../Transaction%20Processing/Transaction%20Processing), the concept of public and private contracts is notional only.
     5  
     6  ### Creating Public Transactions/Contracts
     7  
     8  Sending a standard Ethereum-style transaction to a given network will make it viewable and executable by all participants on the network.  As with Ethereum, leave the `to` field empty for a contract-creation transaction.
     9  
    10  Example JSON RPC API call to send a public transaction:
    11  
    12  ``` json
    13  {    
    14      "jsonrpc":"2.0",
    15      "method":"eth_sendTransaction",
    16      "params":[
    17          {
    18              "from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
    19              "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
    20              "gas": "0x76c0", // 30400
    21              "gasPrice": "0x9184e72a000", // 10000000000000
    22              "value": "0x9184e72a", // 2441406250
    23              "data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
    24          }
    25      ],
    26      "id":1
    27  }
    28  ```
    29  
    30  See the [Quorum API](../api) page for details on the `sendTransaction` call, which includes some modifications to the standard Ethereum call.
    31  
    32  !!! info
    33      See the Contract Design Considerations sections below for important points on creating Quorum contracts
    34  
    35  ### Creating Private Transactions/Contracts
    36  In order to make a transaction/smart contract private and therefore only viewable and executable by a subset of the network, send a standard Ethereum Transaction but include the Quorum-specific `privateFor` parameter.  `privateFor` is used to provide the list of participants for the transaction/contract.  Each participant is identified by a Privacy Manager public key. 
    37  
    38  Example JSON RPC API call to send a private transaction:
    39  
    40  ``` json
    41  {
    42      "jsonrpc":"2.0",
    43      "method":"eth_sendTransaction",
    44      "params":[
    45          {
    46              "from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
    47              "to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
    48              "gas": "0x76c0", // 30400
    49              "gasPrice": "0x9184e72a000", // 10000000000000
    50              "value": "0x9184e72a", // 2441406250
    51              "data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
    52              "privateFor": ["$PUBKEY1, $PUBKEY2"]
    53          }
    54      ],
    55      "id":1
    56  }
    57  ```
    58  
    59  See the [Quorum API](../api) page for details on the `sendTransaction` call, which includes some modifications to the standard Ethereum call.
    60  
    61  !!! info
    62      See the Contract Design Considerations sections below for important points on creating Quorum contracts
    63  
    64  ### Quorum Contract Design Considerations
    65  
    66  1. *Private contracts cannot update public contracts.*  This is because not all participants will be able to execute a private contract, and so if that contract can update a public contract, then each participant will end up with a different state for the public contract.
    67  2. *Once a contract has been made public, it can't later be made private.*  If you do need to make a public contract private, it would need to be deleted from the blockchain and a new private contract created.
    68  
    69  ## Setting up a multi-node network
    70  
    71  The [quorum-examples 7nodes](../Quorum-Examples) source files contain several scripts demonstrating how to set up a private test network made up of 7 nodes.  
    72  
    73  ## Permissioned Networks
    74  
    75  Node Permissioning is a feature of Quorum that is used to define:
    76  
    77  1. The nodes that a particular Quorum node is able to connect to
    78  2. The nodes that a particular Quorum node is able to receive connections from
    79  
    80  Permissioning is managed at the individual node level by using the `--permissioned` command line flag when starting the node.
    81  
    82  If a node is started with `--permissioned` set, the node will look for a `<data-dir>/permissioned-nodes.json` file.  This file contains the list of enodes that this node can connect to and accept connections from.  In other words, if permissioning is enabled, only the nodes that are listed in the `permissioned-nodes.json` file become part of the network. 
    83  
    84  If `--permissioned` is set, a `permissioned-nodes.json` file must be provided. If the flag is set but no nodes are present in this file, then the node will be unable to make any outward connections or accept any incoming connections.
    85  
    86  The format of `permissioned-nodes.json` is similar to `static-nodes.json`:
    87  
    88  ```json
    89  [
    90    "enode://enodehash1@ip1:port1",
    91    "enode://enodehash2@ip2:port2",
    92    "enode://enodehash3@ip3:port3"
    93  ]
    94  ```
    95  
    96  For example, including the hash, a sample file might look like:
    97  
    98  ```json
    99  [
   100    "enode://6598638ac5b15ee386210156a43f565fa8c48592489d3e66ac774eac759db9eb52866898cf0c5e597a1595d9e60e1a19c84f77df489324e2f3a967207c047470@127.0.0.1:30300"
   101  ]
   102  ```
   103  
   104  In the current release, every node has its own copy of `permissioned-nodes.json`. In a future release, the permissioned nodes list will be moved to a smart contract, thereby keeping the list on-chain and requiring just one global list of nodes that connect to the network.
   105  
   106  ### Initialize chain
   107  
   108  The first step is to generate the genesis block.
   109  
   110  The `7nodes` directory in the `quorum-examples` repository contains several keys (using an empty password) that are used in the example genesis file:
   111  
   112  ```
   113  key1    vote key 1
   114  key2    vote key 2
   115  key3    vote key 3
   116  key4    block maker 1
   117  key5    block maker 2
   118  ```
   119  
   120  Example genesis file (copy to `genesis.json`):
   121  ``` json
   122  "config": {
   123      "homesteadBlock": 0,
   124      "byzantiumBlock": 0,
   125      "chainId": 10,
   126      "eip150Block": 0,
   127      "eip155Block": 0,
   128      "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
   129      "eip158Block": 0,
   130      "isQuorum": true
   131    },
   132  ```
   133  
   134  Now we can initialize geth:
   135  
   136  ```
   137  geth init genesis.json
   138  ```
   139  
   140  ### Setup Bootnode
   141  Optionally you can set up a bootnode that all the other nodes will first connect to in order to find other peers in the network. You will first need to generate a bootnode key:
   142  
   143  1. To generate the key for the first time:
   144  
   145      ``` bash
   146      bootnode -genkey tmp_file.txt  // this will start a bootnode with an enode address and generate a key inside a “tmp_file.txt” file`
   147      ```
   148  
   149  2. To later restart the bootnode using the same key (and hence use the same enode url):
   150  
   151      ``` bash
   152      bootnode -nodekey tmp_file.txt
   153      ```
   154  
   155      or
   156  
   157      ``` bash
   158      bootnode -nodekeyhex 77bd02ffa26e3fb8f324bda24ae588066f1873d95680104de5bc2db9e7b2e510 // Key from tmp_file.txt
   159      ```
   160  
   161  ### Start node
   162  
   163  Starting a node is as simple as `geth`. This will start the node without any of the roles and makes the node a spectator. If you have setup a bootnode then be sure to add the `--bootnodes` param to your startup command:
   164  
   165  `geth --bootnodes $BOOTNODE_ENODE`
   166  
   167  ### Adding New Nodes:
   168  Any additions to the `permissioned-nodes.json` file will be dynamically picked up by the server when subsequent incoming/outgoing requests are made. The node does not need to be restarted in order for the changes to take effect. 
   169  
   170  ### Removing existing nodes:
   171  Removing existing connected nodes from the `permissioned-nodes.json` file will not immediately drop those existing connected nodes. However, if the connection is dropped for any reason, and a subsequent connect request is made from the dropped node ids, it will be rejected as part of that new request.
   172  
   173  ## Quorum API
   174  Please see the [Quorum API](../api) page for details.
   175  
   176  ## Network and Chain ID
   177  
   178  An Ethereum network is run using a Network ID and, after [EIP-155](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md), a Chain ID.
   179  
   180  Before EIP-155, the names "Network ID" and "Chain ID" were used interchangeably, but after this they have separate meanings.
   181  
   182  The network ID is a property of a peer, NOT of the chain the peer is managing. A network ID can be passed in via the command line by `--networkid <id>`. It's purpose is to separate peers that are running under a different network ID. Therefore, you  cannot sync with anyone who is running a node with a different network ID. However, since it is trivial to change this, it is a less secure version of Quorum's `--permissioned` flag, and it only used for simple segregation.
   183  
   184  The chain ID is a property of the chain managed by the node. It is used for replay protection of transactions - prior to EIP-155, a transaction run on one chain could be copied and sent to a different chain by anyone, since the transaction is already signed.
   185  
   186  Setting the chain ID has the effect of changing one of the parameters of a transaction, namely the `V` parameter.
   187  As the EIP explains, the `v` parameter is set to `2*ChainID + 35/36`. For the Ethereum Foundation Mainnet, which has a chain ID of `1`, this means that all transactions have a value of either `37` or `38`.
   188  
   189  The chain ID set in the genesis configuration file, under the `config` section, and is only used when the block number is above the one set at `eip155Block`. See the [quorum-examples genesis files](../genesis) for an example. It can be changed as many times as needed whilst the chain is below the `eip155Block` number and re-rerunning `geth init` - this will not delete or modify any current sync process or saved blocks!
   190  
   191  In Quorum, transactions are considered private if the `v` parameter is set to `37` or `38`, which clashes with networks which have a Chain ID of `1`. For this reason, Quorum will not run using chain ID `1` and will immediately quit if started with such a configuration from version 2.1.0 onwards.
   192  If you are running a version prior to version 2.1.0, EIP-155 signing is not used, thus a chain ID of `1` was allowed; you will need to change this using `geth init` before running an updated version.
   193  
   194  
   195  # Zero Knowledge Work
   196  ## ZSL Proof of Concept
   197  
   198  J.P. Morgan and the Zcash team partnered to create a proof of concept (POC) implementation of ZSL for Quorum, which enables the issuance of digital assets using ZSL-enabled public smart contracts (z-contracts). We refer to such digital assets as “z-tokens”. Z-tokens can be shielded from public view and transacted privately. Proof that a shielded transaction has been executed can be presented to a private contract, thereby allowing the private contract to update its state in response to shielded transactions that are executed using public z-contracts. 
   199  
   200  This combination of Constellation/Tessera’s private contracts with ZSL’s z-contracts, allows obligations that arise from a private contract, to be settled using shielded transfers of z-tokens, while maintaining full privacy and confidentiality.
   201  
   202  For more information, see the [ZSL](../../ZSL) page of this wiki.
   203  
   204  ## Anonymous Zether
   205  
   206  This is a private payment system, an _anonymous_ extension of Bünz, Agrawal, Zamani and Boneh's [Zether protocol](https://crypto.stanford.edu/~buenz/papers/zether.pdf).
   207  
   208  The outlines of an anonymous approach are sketched in the authors' original manuscript. We develop an explicit proof protocol for this extension, described in the technical note [AnonZether.pdf](https://github.com/jpmorganchase/anonymous-zether/blob/master/docs/AnonZether.pdf). We also provide a full implementation of the anonymous protocol (including a proof generator, verification contracts, and a client / front-end).
   209  
   210  For more information, see the [Anonymous Zether](https://github.com/jpmorganchase/anonymous-zether/) repo.
   211  
   212  # Quorum Genesis Options
   213  ## Configurable transaction size:
   214  
   215  Quorum allows operators of blockchains to increase maximum transaction size of accepted transactions via the genesis block. The Quorum default is currently increased to `64kb` from Ethereum's default `32kb` transaction size.  This is configurable up to `128kb` by adding `txnSizeLimit` to the config section of the genesis file:
   216  
   217  ``` json
   218  "config": {
   219      "chainId": 10,
   220      "isQuorum":true.
   221      ...
   222      "txnSizeLimit": 128
   223  }
   224  ```
   225  
   226  ## Contract code size:
   227  
   228  Quorum allows operators of blockchains to increase maximum contract code size of accepted smart contracts via the genesis block. The Quorum default is currently increased to `32kb` from Ethereum's default `24kb` contract code size.  This is configurable up to `128kb` by adding `maxCodeSize` to the config section of the genesis file:
   229  
   230  ``` json
   231  "config": {
   232      "chainId": 10,
   233      "isQuorum":true.
   234      ...
   235      "maxCodeSize": 128
   236  }
   237  ```